package com

import (
	"github.com/astaxie/beego/validation"
)

//主要是补充beego一些方法不足

func ValidErrorToMapByField(validErrors []*validation.Error) map[string]*validation.Error {
	mapErrors := make(map[string]*validation.Error)
	dataLen := len(validErrors)
	if dataLen <= 0 {
		return mapErrors
	}

	for i := 0; i < dataLen; i++ {
		vErr := validErrors[i]
		mapErrors[vErr.Field] = vErr
	}

	return mapErrors
}
